package com.cmdandroid.icebutton;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class ICEButtonEditMessageActivity extends ICEButtonActivity {

	EditText messageText;
	@Override
	 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_message);
        
       messageText =
        	(EditText) findViewById(R.id.editText_EditMessage_Message);
     
        
        initButtons();
        
        
	}
	
	public void initButtons(){
		Button saveButton = 
			(Button) findViewById(R.id.button_EditMessage_SaveButton);
		Button clearButton = 
			(Button) findViewById(R.id.button_EditMessage_ClearButton);
		Button cancelButton = 
			(Button) findViewById(R.id.button_EdtiMessage_CancelButton);
		
		saveButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent result = new Intent();
				Bundle b = new Bundle();
				b.putString(MESSAGEDATAKEY, messageText.getText().toString());
				result.putExtras(b);
				setResult(Activity.RESULT_OK, result);
				finish();
			}
		});
		
		clearButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				messageText.setText("");
				
			}
		});
		
		cancelButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}
}
